package com.chinasoftinc.facommon.view.login;

import ohos.aafwk.content.Intent;
import ohos.utils.zson.ZSONObject;

import com.chinasoftinc.facommon.FAConfigMgr;
import com.chinasoftinc.facommon.utils.LogUtil;
import com.chinasoftinc.facommon.view.BaseAceAbility;
import com.chinasoftinc.facommon.view.login.abilitypresent.BleLoginAbilityPresent;
import com.chinasoftinc.facommon.view.login.abilitypresent.LoginAbilityPresent;
import com.chinasoftinc.facommon.view.login.abilitypresent.WifiLoginAbilityPresent;

/**
 * 登录页面, 起始页
 *
 * @since 2022-05-13
 */
public class LoginAbility extends BaseAceAbility {
    public static final String KEY_DEVICE_ID = "deviceId";
    private static final String TAG = "MainAbility";
    private static final int WINDOW_MODAL = 3;
    private LoginAbilityPresent present;

    @Override
    public void onStart(Intent intent) {
        sendRestartEvent();
        intent.setParam("window_modal", WINDOW_MODAL);
        LogUtil.info(TAG, "onStart intent" + ZSONObject.toZSONString(intent.getParams()));
        present = FAConfigMgr.get().isBleMode() ? new BleLoginAbilityPresent(this) : new WifiLoginAbilityPresent(this);
        present.onStart(intent);
        super.onStart(intent);
        present.startAbility();
    }

    @Override
    protected boolean requestRestart() {
        return false;
    }

    @Override
    public void onStop() {
        super.onStop();
        present.onStop();
    }
}
